<!-- <!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
    </head>
    <body>

        <script>
            const _getParams = (url) => {
                // 补全代码
                if(url.indexOf('?') === -1) return {}
                const load = {}
                url.split('?')[1].split('&').forEach(item=>{
                    const temp = item.split('=');
                    load[temp[0]] = temp[1]
                })
                return load
            }
            console.log(_getParams('https://nowcoder.com/online?id=1&salas=1000'))
        </script>
    </body>
</html> -->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
</head>
<!-- 描述
请补全JavaScript代码，要求将字符串参数URL中的参数解析并以对象的形式返回。
示例1
输入：
getParams('https://nowcoder.com/online?id=1&salas=1000')
复制
输出：
{id:1, salas: 100} -->

<body>

  <script>
    // 将字符串参数URL中的参数解析并以对象的形式返回
    const _getParams = (url) => {
      // 补全代码
      return Object.fromEntries(url.match(/\w*=\w*/g).map(item =>
        item.split('=')
      ))
    }
    console.log(_getParams('https://nowcoder.com/online?id=1&salas=1000'))
  </script>
</body>

</html>